package servlet;

import javax.servlet.RequestDispatcher;

import javabean.Factory;


public class BookChangeIsCheckServlet extends BaseServlet{
	/**
	 * 
	 */
	private static final long serialVersionUID = -8538076142868886263L;
	
	public void service() throws Exception{
		String bid = request.getParameter("bid") ;
		String ischeck1 = request.getParameter("ischeck");
		String uid = (String)request.getSession().getAttribute("uid");
		int ischeck = -1;
		if(uid!=null && !"".equals(uid)){
			try{
				if(ischeck1!=null && !"".equals(ischeck1)){
					ischeck = Integer.parseInt(ischeck1);
				}
				if(Factory.getBookDAOInstance().changeBookIsCheck(bid, ischeck)){
					response.getWriter().write("{\"success\":true,\"msg\":\"更改成功\"}");
				}else{
					response.getWriter().write("{\"success\":false,\"msg\":\"更改失败\"}");
				}
			}
			catch(Exception e){
				response.getWriter().write("{\"success\":false,\"msg\":\"哎呀，服务器出错啦\"}");
			}
		}else{
			//跳转
			RequestDispatcher dispatcher = request.getRequestDispatcher("/login");
			dispatcher.forward(request, response) ;
		}	
	}
}
